
package net.ocps.tchs.GovSim;

import java.awt.Font;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.Map;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;

public class MainMenu implements Screen {
        screenSwitcher game;
    	private OrthographicCamera camera;
    	private SpriteBatch batch;
    	private Texture texture;
    	private Sprite sprite;
    	private Stage stage;
    	private TextureAtlas atlas;
    	private Skin skin;
    	private Table table;
    	private TextButton buttonExit,buttonPlay;
    	private TextButtonStyle Style;
    	private BitmapFont font;
         public MainMenu(screenSwitcher game) {
          this.game = game;
  		float w = Gdx.graphics.getWidth();
  		float h = Gdx.graphics.getHeight();
    	font = new BitmapFont();
  		camera = new OrthographicCamera(1, h/w);
  		batch = new SpriteBatch();
  		
  		texture = new Texture(Gdx.files.internal("data/libgdx.png"));
  		texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  		
  		TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);
  		
  		sprite = new Sprite(region);
  		sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
  		sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
  		sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
         }
        @Override
        public void render(float delta) {
        	Gdx.gl.glClearColor(0, 0, 0, 1);
    		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    		
    		
    		stage.act(delta);
        	stage.draw();
        	
    		
    	//	batch.setProjectionMatrix(camera.combined);
    	//	batch.begin();
    	//	sprite.draw(batch);
    	//	batch.end();
        }

        @Override
        public void resize(int width, int height) {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void show() {


        	stage = new Stage();
        	Gdx.input.setInputProcessor(stage);
        	
        	atlas = new TextureAtlas(Gdx.files.internal("ui/button.pack"));
        	
        	skin = new Skin(atlas);
        	
        	table = new Table(skin);
        	table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        	TextButtonStyle Style = new TextButtonStyle();
        	Style.up = skin.getDrawable("button.up");
        	Style.down = skin.getDrawable("button.down");
        	Style.pressedOffsetX = 1;
        	Style.pressedOffsetY = -1;
        	Style.font = font;
        	
        	buttonExit = new TextButton("Exit", Style);
        	buttonExit.pad(20);
        			
        	
        	table.add(buttonExit);
        	table.debug();
        	stage.addActor(table);
        	
        			
        }

        @Override
        public void hide() {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void pause() {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void resume() {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void dispose() {
                // TODO Auto-generated method stub
                
        }

}